#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
    int month[] = { 0, 31, 28, 31, 30, 31, 30 ,31, 31, 30, 31, 30, 31 };
    int y = 0;
    int m = 0;
    int d = 0;
    scanf("%d %d %d", &y, &m, &d);
    if ((y % 100 != 0 && y % 4 == 0) || (y % 400 == 0))
    {
        month[2] = 29;
    }

    int day = d;
    int i = 0;
    for (i = 1; i < m; i++)
    {
        day = day + month[i];
    }

    printf("%d", day);
    return 0;
}